<?php 
session_start();
include("db_connect.php");


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="Basciautosales store the place where you can buy trade set build your own dream cars at its your ways" />
<meta name="description" content="Basciautosales store the place where you can buy trade set build your own dream cars at its your ways" />


<?php include("include/jquery.php");?>
	<!-- Add fancyBox main JS and CSS files -->
	<script type="text/javascript" src="source/jquery.fancybox.js?v=2.1.4"></script>
	<link rel="stylesheet" type="text/css" href="source/jquery.fancybox.css?v=2.1.4" media="screen" />
	<!-- Add Button helper (this is optional) -->
	<link rel="stylesheet" type="text/css" href="source/helpers/jquery.fancybox-buttons.css?v=1.0.5" />
	<script type="text/javascript" src="source/helpers/jquery.fancybox-buttons.js?v=1.0.5"></script>
	<!-- Add Thumbnail helper (this is optional) -->
	<link rel="stylesheet" type="text/css" href="source/helpers/jquery.fancybox-thumbs.css?v=1.0.7" />
	<script type="text/javascript" src="source/helpers/jquery.fancybox-thumbs.js?v=1.0.7"></script>
	<!-- Add Media helper (this is optional) -->
	<script type="text/javascript" src="source/helpers/jquery.fancybox-media.js?v=1.0.5"></script>

	
<?php
	if(isset($_GET['status'])){
		if($_GET['status'] == "success"){
			echo '
				<script>
					alert("Basciautosales will verify your request");
				</script>
			';
		
		}
		else{
		echo '
				<script>
					alert("Something went wrong please try again");
				</script>
			';
		}
		
	}
?>	
	
	
<script type="text/javascript">

$(document).ready(function() {
$("#prev3").hide();
$("#prev").hide();


$('.fancybox-thumbs').fancybox({
		prevEffect : 'fade',
		nextEffect : 'fade',
		closeBtn  : true,
		arrows    : true,
		nextClick : true,
		helpers : {
		thumbs : {
			width  : 50,
			height : 50
		}
	}
});


				
$("#colorname #color").click(function () {
	var colorname = $(this,this).attr("name");
	var brand = $("#colorbrand");
	var model = $("#colormodel");
	brand = brand.val();
	model = model.val();
	
	document.documentElement.style.overflow = 'hidden'; 
	$("#msgbox").html(loader).load("scripts/carColorSelection.php?color="+colorname+"&brand="+brand+"&model="+model);
	
	$("#msgbox").dialog({
		title:"Color "+colorname+ "/Brand:"+brand+ "/Model:" + model,
		modal:true,
		width:1000,
		height:"auto",
		show: "fade",
		resizeble:true,
		position:['center',0],
	});	
	$("#msgbox").siblings('.ui-resizable-se').remove();
	
	
});

$('div#msgbox').bind('dialogclose', function(event) {
   document.documentElement.style.overflow = 'auto';
 });
				
});//end of document.ready

function totrade(){

var a = $("#car_id");

$("#msgbox").html(loader).load("trader.php?car_id="+a.val());
$("#msgbox").dialog({
	modal:true,
	width:738,
	height:'auto',
	show: "fade",
	resizeble:true,
	top:500,
	center:true,
	position:['center',0],
	buttons: {
	},
});	

}



function previews(){	
		
		$("#prev").dialog({
					modal:true,
					width:650,
					height:480,
					show: "fade",
					resizeble:false,
					top:500,
					buttons: {
					},
				});	
	
	}
function preview2(){	
		
		$("#prev2").dialog({
					modal:true,
					width:650,
					height:480,
					show: "fade",
					resizeble:false,
					center:true,
					buttons: {
					},
				});	
	
	}	
	
	
	
</script>

</head>

<body> <div id=" msgbox"></div>
<div id="msgbox"></div>
<div id="templatemo_wrapper">
	<!--header-->
		<?php include("include/header.php");?>
	<!--header-->
    
    <div id="templatemo_main">
   		<!--sidebar-->
		
		
        <div id="content" class="float_r" style="width: 860px; padding: 50px;">
			
			<!--preview-->
			
			<?php


			$cid = $_GET['pageid'];
			$title = "";
			$price = "";
			$condition ="";
			$year ="";
			$brand ="";
			$model ="";
			$cparts = "";
			$trade = "";
			$fuel ="";
			$sql = "SELECT * FROM tblswaping where id='$cid'";
			$result = mysql_query($sql) or die(mysql_error());
			if(mysql_num_rows($result) < 1){
			
				echo '<div style="margin-top:10px;"><h3 style="color:red;">No Item Found</h3></div>';
				die();
			}
			
			while($row = mysql_fetch_array($result)){
				
				$title = $row['name'];
				$price = $row['price'];
				$condition = $row['conditions'];
				$cpart = $row['cparts'];
				$cat = $row['categories'];
				$year = $row['year'];
				$brand = $row['brand'];
				$model = $row['model'];
				$color = $row['color'];
				$trans = $row['transmission'];
				$modeofpayment = $row['modeofpayment'];
				$id = $row['id'];
				
				$fuel = $row['fuel'];
				$img = $row['filename'];
				$dateposted  = $row['timepost'];
				$description  = $row['description'];
			}
				/*displying all the images from the data base*/
				$display = "";
				$a = Array();
				$d = array();
				$d = explode("/",$dateposted);
				
				$imgarr = explode("+",$img);
								
					$a ="";
					//srand(time()); 
						$display = '<ul id="imglist" style="list-style:none; clear:both ">';
					for($i=0;$i<count($imgarr)-1;$i++){
										
						$display .= '<font style="float:left; width:145px; margin:4px;"><li style="border:1px solid red;"><a class="fancybox-thumbs" data-fancybox-group="thumb" href="images/vehicles/'.$imgarr[$i].'"><img width="143px" height="125px" src="images/vehicles/'.$imgarr[$i].'" alt="" /></a></li></font>';
					
					}
				
					?>
	

	
			<div id="placeorder_main">
				<h2 style="color:red"> <?php echo $title; ?></h2>
					<div  id="preview_l">
					
						<table> 
						<tr>
							<td>
								<?php
									
									echo '<a data-fancybox-group="thumb" href="images/vehicles/'.$imgarr[0].'"><img width="500px" height="340px" style="border:7px solid #dedede; border-radius:5px;-moz-border-radius:5px;box-shadow: 3px 3px 5px #888888;" src="images/vehicles/'.$imgarr[0].'" alt="" /></a>';
									echo '<div id="prev">"<img style="border-radius:5px;-moz-border-radius:5px;box-shadow: 10px 10px 5px #888888; " src="images/vehicles/'.$imgarr[0].'" width="800px" height="600px"></div>';
								?>
							</td>
							<td valign="bottom">
								<div id="colorpreview" style=" margin-left:20px;">
								<font >Available Colors</font></br>
								<div  style="float:left; margin-left:-45px; position:relative; width:300px;">
								<ul>
								<?php 
									$sql = mysql_query("SELECT * FROM tblswaping Where brand = '$brand' and model = '$model' GROUP BY color")or die(mysql_error());
									while($row = mysql_fetch_array($sql)){
										echo'<li>
												<a href="#" id="colorname" name="'.$row['color'].'" > 
													<div name="'.$row['color'].'" style="width:15px; height:15px; border:1px solid #dedede; background-color:'.$row['color'].'" id="color" title="'.$row['color'].'"></div>
													
										
												</a>
											</li>';
		
											
									}
								echo'<input type="hidden" id="colorbrand" value="'.$brand.'" >
									<input type="hidden" id="colormodel" value="'.$model.'" >
									';
								?>
								</ul>
								</div>
								</div>
							</td>
						</tr>
						<tr>
							<td>
								<a  href="#img" style="font-size:13px;"><font align="center" style="color:red;">View :<?php echo count($imgarr)-1;?> images</font></a>
							</td>
							
						</tr>
						<?php
						if($cat == "Acccessories"  && !empty($cpart) ){
						echo '<tr>';
						echo '	<td>';
						echo '		<button onclick="add2cart('.$cid.')" id="add2cart" name="">add to cart</button>';
						echo '	</td>';
						echo '</tr>';
						}
						else{
						echo '<tr>';
						echo '	<td>';
						echo ' <input type="hidden" id="car_id" value="'.$id.'">';
						echo '		<a href="trader2.php?car_id='.$id.'"  id="trademe" style="color:red; font-size:20px; ">Trade me</a>';
						echo '	</td>';
						echo '</tr>';
							
						}
						?>
						</table>
					</div>
					<div id="preview_r" >
						
						<!--div id="preview_mid_content"-->
							<table>
								<tr>
									<td ><label align="left">Price:</label></td>
									<td><font style="font-size:30px; color:red;">P<?php echo $price;?></font></td>
								</tr>
								<tr>
									
									<?php
										if($cat != "Acccessories"){
										echo '<td ><label align="left">Payment:</label></td>';
										echo '<td><font style="font-size:12px; color:red;"><?php echo $modeofpayment;?></font></td>';
										}
										else{
											echo '<td ><label align="left">Payment:</label></td>';
											echo '<td><font style="">Cash</font></td>';
										}
									?>
								</tr>
								<tr>
									<td><label>Item code:</label></td>
									<td><font style="">basci-<?php echo $cid; ?></font></td>
								</tr>
								<tr>
									<td><label>Date Posted:</label></td>
									<td><font style=""><?php echo $d[0]; ?></font></td>
								</tr>
								<tr>
									<td align="left">Condition:<label></label></td>
									<td><font><?php  echo $condition; ?></font></td>
								</tr>
								<tr>
									<td align="left"><label>Category:</label></td>
									<td><font><?php  echo $cat; ?></font></td>
								</tr>
								
								<?php
								$cp = "";
								if(!empty($cpart)){
								$cp .='	<tr>';
								$cp .='	<td align="left">Part:<label></label></td>';
								$cp .='	<td><font>'.$cpart.'</font></td>';
									
									echo $cp;	
								}else{
								$cp .='	</tr>';
								$cp .='	<tr>';
								$cp .='		<td align="left"><label>Transmission:</label></td>';
								$cp .='		<td><font>'.$trans .'</font></td>';
								$cp .='	</tr>';
								
									echo $cp;
								}
									
								?>
								
								<?php?>
								<tr>
									<td valign="top"><label>Description:</label></td>
									<td ><p align="justify"><?php  echo $description; ?></p></td>
								</tr>
											
								
							
							</table>
							<div width="100%">
								<h4 id="img">Images</h4>
									<?php 
								
										echo $display;
											
										
									?>
							
							</div>
							
							
						<!--/div-->
						
					</div>
					
		
		
			<!--end preview-->
        </div> 
		</div> 
        <div class="cleaner"></div>
    </div> <!-- END of templatemo_main -->
    
     <!--footer-->
	<?php include("include/footer.php");?>
    
</div> <!-- END of templatemo_wrapper -->

</body>
</html>